package com.link.play.fit.ai.ext

import android.annotation.SuppressLint
import android.net.Uri
import android.os.Build
import androidx.core.content.FileProvider
import com.link.play.fit.ai.utils.AppX
import java.io.File

inline val kFileProviderAuthority: String get() = "${AppX.context.packageName}.fileprovider"

/** 获取文件 Uri, 兼容 [FileProvider] */
@SuppressLint("ObsoleteSdkInt")
fun File.toUriCompat(): Uri {
    return if (Build.VERSION.SDK_INT >= 24) {
        FileProvider.getUriForFile(AppX.context, kFileProviderAuthority, this)
    } else {
        Uri.fromFile(this)
    }
}